#include"QueryResult.hpp"
#include<vector>
using namespace NNU::DGGS::Kernel;


QueryResult::QueryResult()
{
    this->codeData=new std::vector<DGGSElementCode>();
    this->size = 0;
}
QueryResult::~QueryResult()
{
    this->codeData->clear();
	delete this->codeData;
    this->size=0;
}

bool QueryResult::setData(DGGSElementCodeIter* iter, int codeNum)
{
    this->codeData->clear();
    size=0;
	if (iter == nullptr)
		return false;
	for (int i = 0; i < codeNum; i++)
		codeData->push_back(iter[i].code);
	size = codeNum;
	return true;
}

DGGSElementCode QueryResult::getGridCodeByIndex(int index)
{
	if (index < size && index >= 0)
	{
		std::vector tempData = *(codeData);
		return tempData[index];
	}
	else
	{
		DGGSElementCode code;
		code.level = -1;
		return code;
	}

}

int QueryResult::getSize()
{
    return this->size;
}
